public class RecordTodayJointCallControl{
/**********************************************************************
 Name:  RecordTodayJointCallControl()
 Purpose:  record joint call                                                   
======================================================
History                    
-------                                                            
VERSION  AUTHOR            DATE              DETAIL                                
   1.0 -      li siheng         14/03/2011         Create          : 
************************************************************************/

public string msg{get;set;} 
public string msgstyle{get;set;}
public boolean ShowSaveButton{get;set;}
public jointcall__c searchRecord{
    get
    {
        if(searchRecord == null)
            searchRecord=new JointCall__c();
        return searchRecord;        
    }
    set;
}
public list<jointcall__c> JointCallList{
    get{
        if(JointCallList==null)
            JointCallList=new list<JointCall__c>();

        return jointcalllist;
    }
    set;
}

public RecordTodayJointCallControl(ApexPages.StandardController controller) {
    this.controller = controller;
    
    searchRecord = new jointcall__c();
    searchRecord.SearchDate__c = date.today();
    msgstyle='collapse;';
    showsavebutton=true;
    jointcalllist=[select id,MSR__c,CallPlan__c,HCPEvaluation__c,MamaChoice__c,PClassExecute__c,BrandUseInHospital__c,Remark__c from jointcall__c where Owner__c =: UserInfo.getUserId() and CallDate__c =:date.today()];

    
}

public void Search()
{
    msg = null;
    
    if(searchRecord.SearchDate__c > date.today())
    {
        msg='不能选择今天以后的日期';
    }
    else
    {
        if(searchRecord.SearchDate__c != null)
        {
            jointcalllist=[select id,MSR__c,CallPlan__c,HCPEvaluation__c,MamaChoice__c,PClassExecute__c,BrandUseInHospital__c,Remark__c from jointcall__c where Owner__c =: UserInfo.getUserId() and CallDate__c =:searchRecord.SearchDate__c];
        }
        else
        {
            msg='请先选择日期';
        }
        if(jointcalllist.size()==0){
            msg='您今天没有可记录的共同拜访计划。';
            showsavebutton=false;
        }            
    } 
   
}

private final ApexPages.StandardController controller;

public void submit(){
    if(jointcalllist.size()>0){ 

        update jointcalllist;
    }
}


}